package com.hubu.service.impl;

import com.hubu.domain.User;
import com.hubu.mapper.UserMapper;
import com.hubu.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @description:
 * @author: hubu
 * @time: 2023/4/12 19:50
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    UserMapper userMapper;



    @Override
    public User getUser(String token) {
        return userMapper.getUserByToken(token);

    }
    public User getUserByName(String username){
        return userMapper.getUserByName(username);
    }

    @Override
    public void saveToken(Integer id,String token) {
        userMapper.saveToken(id,token);
    }

    @Override
    public Integer register(User user) {
        String avatar = "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif";
        return userMapper.register(user,avatar);
    }

    @Override
    public Integer checkUsername(String username) {

        try {
            return userMapper.checkUsername(username);
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
    }
}
